package niuke;

import java.util.Scanner;

/**
 * @author cyt
 * @create 2020-05-21 19:01
 */
public class A {
    // aba aba baab
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        char[] chars = str.toCharArray();

        char ch = chars[0];
        int len = chars.length;
        int[] ans = new int[len];
        int k = 0;
        //  System.out.println(ch);
        for (int i = 0; i < chars.length; i++) {
            if (ch == chars[i]) {
                ans[k++] = i + 1;
            }
        }

        int n = 0;
        int index = ans[1] - ans[0] + 1;
        for (int i = 0; i < ans.length; i++) {
            if (ans[i] % index == 0) {
                n = i;
            }
        }
        System.out.println(n - 1);

    }
}
